package com.example.mvvm

open class Person(var name: String,
                  var age: Int) {

    fun eat() {
        println(name + "is eat, he is" + age)
    }
}

open class Person1(name: String,
                  age: Int) {

    var name: String = ""
    var age = 0

    init {
        this.name = name
        this.age = age
    }

    fun eat() {
        println(name + "is eat, he is" + age)
    }
}

open class Person2 {

    var name: String = ""
    var age = 0

    constructor()

    constructor(name: String, age: Int): this() {
        this.name = name
        this.age = age
    }

    fun eat() {
        println(name + "is eat, he is" + age)
    }

}

open class Person4 constructor(name: String, age: Int) {

    var name: String = ""
    var age = 0

    fun eat() {
        println(name + "is eat, he is" + age)
    }
}

class Person5(var sno: String = "",
              var gradle: Int = 0,
              var name: String = "",
              var age: Int = 0)

class Test() {
    val a = Person5() //无参
    val a1 = Person5("sno")
    val a2 = Person5("sno",1)
    val a3 = Person5("sno",1,"name")
    val a4 = Person5("sno",1,"name",18)
    val a5 = Person5(age = 15)
    val a6 = Person5(age = 15, name = "name")
}

